<template>
	<div class="app-container">
		<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px" @submit.native.prevent>
<!--			<el-form-item label="昵称" prop="nickname">-->
<!--				<el-input v-model="queryParams.nickname" placeholder="请输入" clearable @keyup.enter="handleQuery"/>-->
<!--			</el-form-item>-->
			<el-form-item label="手机号码" prop="phone">
				<el-input v-model="queryParams.phone" placeholder="请输入" clearable @keyup.enter="handleQuery"/>
			</el-form-item>
			<el-form-item label="认证状态" prop="authStatus">
				<el-select v-model="queryParams.authStatus" placeholder="请选择" clearable>
					<el-option v-for="dict in auth_status" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
				</el-select>
			</el-form-item>
			<el-form-item label="状态" prop="status">
				<el-select v-model="queryParams.status" placeholder="请选择" clearable>
					<el-option v-for="dict in sys_data_status" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
				</el-select>
			</el-form-item>
			<el-form-item label="是否推荐" prop="isShow">
				<el-select v-model="queryParams.isShow" placeholder="请选择" clearable>
					<el-option v-for="dict in sys_yes_no" :key="dict.value" :label="dict.label" :value="parseInt(dict.value)"/>
				</el-select>
			</el-form-item>
			<el-form-item>
				<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
				<el-button icon="Refresh" @click="resetQuery">重置</el-button>
			</el-form-item>
		</el-form>
		<el-row :gutter="10" class="mb8">
			<el-col :span="1.5">
				<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['um:umClientUser:add']">新增</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate" v-hasPermi="['um:umClientUser:edit']">修改</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete" v-hasPermi="['um:umClientUser:remove']">删除</el-button>
			</el-col>
			<el-col :span="1.5">
				<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['um:umClientUser:export']">导出</el-button>
			</el-col>
			<right-toolbar v-model:showSearch="showSearch" @queryTable="getList" :columns="columns"></right-toolbar>
		</el-row>
		<el-table v-loading="loading" :data="umClientUserList" @selection-change="handleSelectionChange">
			<el-table-column type="selection" width="55" align="center"/>
			<el-table-column label="用户名" align="center" prop="username" v-if="columnVisible('username')"/>
			<el-table-column label="密码" align="center" prop="password" v-if="columnVisible('password')"/>
			<el-table-column label="昵称" align="center" prop="nickname" v-if="columnVisible('nickname')"/>
			<el-table-column label="手机号码" align="center" prop="phone" v-if="columnVisible('phone')" fixed width="120"/>
			<el-table-column label="邮箱" align="center" prop="eamil" v-if="columnVisible('eamil')"/>
			<el-table-column label="用户头像" align="center" prop="avatar" width="100" v-if="columnVisible('avatar')">
				<template #default="scope">
					<image-preview :src="scope.row.avatar" :width="50" :height="50"/>
				</template>
			</el-table-column>
			<el-table-column label="真实姓名" align="center" prop="realname" v-if="columnVisible('realname')"/>
			<el-table-column label="性别" align="center" prop="sex" v-if="columnVisible('sex')">
				<template #default="scope">
					<dict-tag :options="sys_user_sex" :value="scope.row.sex"/>
				</template>
			</el-table-column>
			<el-table-column label="出生日期" align="center" prop="birthday" v-if="columnVisible('birthday')"/>
			<template v-for="attr in attrConf.filter(s=>s.attrType !== 'condition')">
				<el-table-column :label="attr.attrName" align="center" :prop="attr.attrCode" v-if="columnVisible(attr.attrCode)" :width="getWidth(attr.attrCode)" :fixed="getFixed(attr.attrCode)"  >
					<template #default="scope">
						<image-preview v-if="attr.viewType === 'imageUpload'" :src="scope.row.attrDataMap[attr.attrCode]" :width="50" :height="50"/>
						<dict-tag v-else-if="attr.viewType === 'radio' || attr.viewType === 'checkbox' || attr.viewType === 'select'" :options="attrDicts[attr.dictType]" :value="scope.row.attrDataMap[attr.attrCode]" />
						<span v-else>{{ scope.row.attrDataMap[attr.attrCode] }}</span>
					</template>
				</el-table-column>
			</template>
			<el-table-column label="微信公众号openid" align="center" prop="wxmpOpenid" v-if="columnVisible('wxmpOpenid')"/>
			<el-table-column label="微信开放平台openid" align="center" prop="wxopenOpenid" v-if="columnVisible('wxopenOpenid')"/>
			<el-table-column label="微信小程序openid" align="center" prop="wxmaOpenid" v-if="columnVisible('wxmaOpenid')"/>
			<el-table-column label="微信unionid" align="center" prop="wxUnionid" v-if="columnVisible('wxUnionid')"/>
			<el-table-column label="积分" align="center" prop="integral" v-if="columnVisible('integral')"/>
			<el-table-column label="总积分" align="center" prop="integralTotal" v-if="columnVisible('integralTotal')"/>
			<el-table-column label="已使用积分" align="center" prop="integralUsed" v-if="columnVisible('integralUsed')"/>
			<el-table-column label="认证状态" align="center" prop="authStatus" v-if="columnVisible('authStatus')" fixed="right">
				<template #default="scope">
					<dict-tag :options="auth_status" :value="scope.row.authStatus"/>
				</template>
			</el-table-column>

			<el-table-column label="备注" align="center" prop="remark" v-if="columnVisible('remark')"/>
			<el-table-column label="是否推荐" align="center" prop="isShow" v-if="columnVisible('isShow')" fixed="right">
				<template #default="scope">
					<el-switch v-model="scope.row.isShow" :active-value="1" :inactive-value="0" @change="handleStatusChange(scope.row,'isShow','推荐','不推荐')"></el-switch>
				</template>
			</el-table-column>
			<el-table-column label="状态" align="center" prop="status" v-if="columnVisible('status')" fixed="right">
				<template #default="scope">
					<el-switch v-model="scope.row.status" :active-value="0" :inactive-value="1" @change="handleStatusChange(scope.row,'status')"></el-switch>
				</template>
			</el-table-column>
			<el-table-column label="归属部门" align="center" prop="deptId" v-if="columnVisible('deptId')" fixed="right">
				<template #default="scope">
					<span>{{ deptName(scope.row.deptId) }}</span>
				</template>
			</el-table-column>
			<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150" fixed="right">
				<template #default="scope">
					<el-button link type="primary" icon="View" @click="handleView(scope.row)" v-hasPermi="['um:umClientUser:query']" v-noPermi="['um:umClientUser:edit']">查看</el-button>
					<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['um:umClientUser:edit']">修改</el-button>
					<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['um:umClientUser:remove']">删除</el-button>
				</template>
			</el-table-column>
		</el-table>

		<pagination v-show="total>0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList"/>
		<!-- 添加或修改客户端用户对话框 -->
		<el-dialog :title="title" v-model="open" width="1400" append-to-body>
			<el-form ref="umClientUserRef" :model="form" :rules="rules" label-width="80px" :disabled="!isInsert && !isEdit">
				<el-collapse v-model="activeNames">
					<el-collapse-item title="账户信息" name="1">
						<el-row :gutter="20">
							<el-col :span="6">
								<el-form-item label="手机号码" prop="phone">
									<el-input v-model="form.phone" placeholder="请输入" :disabled="!isInsert"/>
								</el-form-item>
							</el-col>
							<!--							<el-col :span="6">-->
							<!--								<el-form-item label="密码" prop="password">-->
							<!--									<el-input v-model="form.password" placeholder="请输入"/>-->
							<!--								</el-form-item>-->
							<!--							</el-col>-->

							<el-col :span="6">
								<el-form-item label="归属部门" prop="deptId">
									<el-tree-select v-model="form.deptId" :data="deptOptions" :props="{ value: 'id', label: 'label', children: 'children' }" value-key="id" placeholder="请选择归属部门" check-strictly default-expand-all filterable :disabled="!checkPermi(['admin'])"/>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="状态" prop="status">
									<el-radio-group v-model="form.status">
										<el-radio v-for="dict in sys_data_status" :key="dict.value" :label="parseInt(dict.value)">{{ dict.label }}</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
							<el-col :span="6">
								<el-form-item label="是否推荐" prop="isShow">
									<el-radio-group v-model="form.isShow" >
										<el-radio v-for="dict in sys_yes_no" :key="dict.value" :label="parseInt(dict.value)">{{dict.label}}</el-radio>
									</el-radio-group>
								</el-form-item>
							</el-col>
<!--							<el-col :span="6">
								<el-form-item label="积分" prop="integral">
									<el-input v-model="form.integral" placeholder="请输入" :disabled="!isInsert"/>
								</el-form-item>
							</el-col>-->
						</el-row>
					</el-collapse-item>
					<el-collapse-item :title="attr.label" :name="index + 2 + ''" v-for="(attr,index) in um_attr_type">
						<el-row :gutter="20">
							<el-col v-if="attrConfMap[attr.value].base" :span="attrConfMap[attr.value].base.colSpan">
								<el-row :gutter="20">
									<el-col :span="24" v-if="attr.value === 'auth'">
										<el-form-item label="认证状态" prop="authStatus">
											<el-radio-group v-model="form.authStatus">
												<el-radio v-for="dict in auth_status" :key="dict.value" :label="parseInt(dict.value)">{{ dict.label }}</el-radio>
											</el-radio-group>
										</el-form-item>
									</el-col>
									<el-col v-for="item in attrConfMap[attr.value].base.list" :span="attrConfMap[attr.value].base.subColSpan">
										<el-form-item :label="item.attrName">
											<el-input clearable v-if="item.viewType === 'input'" v-model="formAttrDataMap[item.attrCode]"/>
											<el-input-number clearable v-else-if="item.viewType === 'inputNumber'" v-model="formAttrDataMap[item.attrCode]" :disabled="item.attrCode === 'NL'"/>
											<el-input clearable type="textarea" v-else-if="item.viewType === 'textarea'" v-model="formAttrDataMap[item.attrCode]"/>
											<el-select clearable v-else-if="item.viewType === 'select'" v-model="formAttrDataMap[item.attrCode]">
												<el-option v-for="dict in attrDicts[item.dictType]" :key="dict.value" :label="dict.label" :value="dict.value"></el-option>
											</el-select>
											<el-radio-group clearable v-else-if="item.viewType === 'radio'" v-model="formAttrDataMap[item.attrCode]">
												<el-radio v-for="dict in attrDicts[item.dictType]" :key="dict.value" :label="dict.value">{{ dict.label }}</el-radio>
											</el-radio-group>
											<el-checkbox-group clearable v-else-if="item.viewType === 'checkbox'" v-model="formAttrDataMap[item.attrCode]">
												<el-checkbox v-for="dict in attrDicts[item.dictType]" :key="dict.value" :label="dict.value">{{ dict.label }}</el-checkbox>
											</el-checkbox-group>
											<el-date-picker clearable v-else-if="item.viewType === 'date'" type="date" value-format="YYYY-MM-DD" placeholder="请选择" v-model="formAttrDataMap[item.attrCode]" @change="changeDate"/>
											<el-time-picker clearable v-else-if="item.viewType === 'time'" value-format="HH:mm:ss" placeholder="请选择" v-model="formAttrDataMap[item.attrCode]"/>
											<el-date-picker clearable v-else-if="item.viewType === 'datetime'" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" v-model="formAttrDataMap[item.attrCode]"/>
											<el-time-select clearable v-else-if="item.viewType === 'timeSelect'" start="06:00" step="00:30" end="23:00" placeholder="请选择" v-model="formAttrDataMap[item.attrCode]"/>
										</el-form-item>
									</el-col>
								</el-row>
							</el-col>
							<el-col v-if="attrConfMap[attr.value].img" :span="attrConfMap[attr.value].img.colSpan">
								<el-row :gutter="20">
									<el-col v-for="item in attrConfMap[attr.value].img.list" :span="attrConfMap[attr.value].img.subColSpan">
										<el-form-item :label="item.attrName">
											<image-upload v-if="item.viewType === 'imageUpload'" v-model="formAttrDataMap[item.attrCode]" :limit="attr.value === 'sign'?100:1"/>
											<file-upload v-else-if="item.viewType === 'fileUpload'" v-model="formAttrDataMap[item.attrCode]" :limit="attr.value === 'sign'?100:1"/>
										</el-form-item>
									</el-col>
								</el-row>
							</el-col>
							<el-col v-if="attrConfMap[attr.value].editor" :span="12" v-for="item in attrConfMap[attr.value].editor.list">
								<el-form-item :label="item.attrName">
									<editor :min-height="192" v-model="formAttrDataMap[item.attrCode]"/>
								</el-form-item>
							</el-col>

						</el-row>
					</el-collapse-item>
					<el-collapse-item title="择偶条件" :name="um_attr_type.length + 2 + ''" >
						<el-row :gutter="20">
							<el-col v-for="item in attrConfMap.condition.base.list" :span="attrConfMap.condition.base.subColSpan">
								<el-form-item :label="item.attrName">
									<el-input readonly v-model="formAttrDataMap[item.attrCode + '_str']" v-if="formAttrDataMap[item.attrCode + '_str']"/>
									<el-input readonly v-model="formAttrDataMap[item.attrCode]" v-else/>
								</el-form-item>
							</el-col>
						</el-row>
					</el-collapse-item>
				</el-collapse>
				<el-form-item label="备注" prop="remark">
					<el-input v-model="form.remark" type="textarea" placeholder="请输入"/>
				</el-form-item>
			</el-form>
			<template #footer v-if="isEdit || isInsert">
				<div class="dialog-footer">
					<el-button type="primary" @click="submitForm">确 定</el-button>
					<el-button @click="cancel">取 消</el-button>
				</div>
			</template>
		</el-dialog>
	</div>
</template>

<script setup name="UmClientUser">
import {
	listUmClientUser,
	getUmClientUser,
	delUmClientUser,
	addUmClientUser,
	updateUmClientUser
} from "@/api/um/umClientUser";
import {
	allUmAttrConf,
} from "@/api/um/umAttrConf";
import {checkPermi} from "@/utils/permission.js";
import useDeptStore from "@/store/modules/dept.js";
import DictTag from "@/components/DictTag/index.vue";
import {getAge} from "@/utils/index.js";

const {proxy} = getCurrentInstance();
const {
	sys_data_status,
	sys_user_sex,
	auth_status,
	um_attr_type,
	sys_yes_no,
} = proxy.useDict('sys_data_status', 'sys_user_sex', 'auth_status', 'um_attr_type', 'sys_yes_no');

const deptStore = useDeptStore();


const umClientUserList = ref([]);
const isEdit = ref(false);
const isInsert = ref(false);
const open = ref(false);
const loading = ref(true);
const showSearch = ref(true);
const ids = ref([]);
const single = ref(true);
const multiple = ref(true);
const total = ref(0);
const title = ref("");
const activeNames = ref(["1", "2", "3", "4", "5", "6"]);

// 列显隐信息(able表示列是否可用，visible用于用户控制显隐)
const columns = ref([
	{label: `id`, able: false, visible: false, key: 'id'},
	{label: `用户名`, able: false, visible: true, key: 'username'},
	{label: `密码`, able: false, visible: true, key: 'password'},
	{label: `昵称`, able: false, visible: true, key: 'nickname'},
	{label: `手机号码`, able: true, visible: true, key: 'phone'},
	{label: `邮箱`, able: false, visible: true, key: 'eamil'},
	{label: `用户头像`, able: false, visible: true, key: 'avatar'},
	{label: `真实姓名`, able: false, visible: true, key: 'realname'},
	{label: `性别`, able: false, visible: true, key: 'sex'},
	{label: `出生日期`, able: false, visible: true, key: 'birthday'},
	{label: `微信公众号openid`, able: false, visible: true, key: 'wxmpOpenid'},
	{label: `微信开放平台openid`, able: false, visible: true, key: 'wxopenOpenid'},
	{label: `微信小程序openid`, able: false, visible: true, key: 'wxmaOpenid'},
	{label: `微信unionid`, able: false, visible: true, key: 'wxUnionid'},
	{label: `积分`, able: true, visible: true, key: 'integral'},
	{label: `总积分`, able: false, visible: true, key: 'integralTotal'},
	{label: `已使用积分`, able: false, visible: true, key: 'integralUsed'},
	{label: `认证状态`, able: true, visible: true, key: 'authStatus'},
	{label: `状态`, able: true, visible: true, key: 'status'},
	{label: `是否推荐`, able: true, visible: true, key: 'isShow'},
	{label: `归属部门`, able: true, visible: true, key: 'deptId'},
	{label: `创建者`, able: false, visible: false, key: 'createBy'},
	{label: `创建时间`, able: false, visible: false, key: 'createTime'},
	{label: `更新者`, able: false, visible: false, key: 'updateBy'},
	{label: `更新时间`, able: false, visible: false, key: 'updateTime'},
	{label: `备注`, able: true, visible: true, key: 'remark'},
]);

const data = reactive({
	form: {},
	queryParams: {
		pageNum: 1,
		pageSize: 10,
		params: {},
		username: null,
		password: null,
		nickname: null,
		phone: null,
		eamil: null,
		avatar: null,
		realname: null,
		sex: null,
		wxmpOpenid: null,
		wxopenOpenid: null,
		wxmaOpenid: null,
		wxUnionid: null,
		integral: null,
		integralTotal: null,
		integralUsed: null,
		authStatus: null,
		status: null,
		deptId: null,
		attrQueryMap:{}
	},
	rules: {}
});

const {queryParams, form, rules} = toRefs(data);
const formAttrDataMap = ref({})

/** 列显隐 */
function columnVisible(key) {
	return proxy.checkColumn(columns.value, key);
}

const WidthList180 = ['XQAH']
const WidthList120 = ['QQ', 'WX', 'SFZH']
const WidthList100 = ['NC', 'SR', 'JJSR']
function getWidth(attrCode) {
	if (WidthList180.indexOf(attrCode) > -1) return 180;
	if (WidthList120.indexOf(attrCode) > -1) return 120;
	if (WidthList100.indexOf(attrCode) > -1) return 100;
	return 80;
}

const fixedLeftList = ['NC','XM']
const fixedRightList = ['']
function getFixed(attrCode){
	if (fixedLeftList.indexOf(attrCode) > -1){
		return 'left';
	}
	if (fixedRightList.indexOf(attrCode) > -1){
		return 'right'
	}
	return false;
}

function changeDate(){
	console.log('changeDate',formAttrDataMap.value,formAttrDataMap.value.SR)
	if (formAttrDataMap.value && formAttrDataMap.value.SR){
		formAttrDataMap.value.NL = getAge(formAttrDataMap.value.SR)
	}

}

/** 查询客户端用户列表 */
function getList() {
	loading.value = true;
	listUmClientUser(queryParams.value).then(response => {
		umClientUserList.value = response.rows;
		total.value = response.total;
		loading.value = false;
	});
}

// 取消按钮
function cancel() {
	open.value = false;
	reset();
}

// 表单重置
function reset() {
	form.value = {
		id: null,
		username: null,
		password: null,
		nickname: null,
		phone: null,
		eamil: null,
		avatar: null,
		realname: null,
		sex: 0,
		birthday: null,
		wxmpOpenid: null,
		wxopenOpenid: null,
		wxmaOpenid: null,
		wxUnionid: null,
		integral: null,
		integralTotal: null,
		integralUsed: null,
		authStatus: 0,
		status: 0,
		deptId: null,
		createBy: null,
		createTime: null,
		updateBy: null,
		updateTime: null,
		remark: null
	};
	formAttrDataMap.value = {}
	proxy.resetForm("umClientUserRef");
}

/** 搜索按钮操作 */
function handleQuery() {
	queryParams.value.pageNum = 1;
	getList();
}

/** 重置按钮操作 */
function resetQuery() {
	proxy.resetForm("queryRef");
	handleQuery();
}

// 多选框选中数据
function handleSelectionChange(selection) {
	ids.value = selection.map(item => item.id);
	single.value = selection.length != 1;
	multiple.value = !selection.length;
}

/** 新增按钮操作 */
function handleAdd() {
	reset();
	open.value = true;
	title.value = "添加客户端用户";
	isInsert.value = true;
	isEdit.value = false;
}

/** 查看按钮操作 */
function handleView(row) {
	isEdit.value = false;
	title.value = "查看客户端用户";
	getInfo(row);
}

/** 修改按钮操作 */
function handleUpdate(row) {
	isEdit.value = true;
	title.value = "修改客户端用户";
	getInfo(row);
}

function getInfo(row) {
	reset();
	const _id = row.id || ids.value
	isInsert.value = false;
	proxy.modal.loading("加载中");
	getUmClientUser(_id).then(response => {
		form.value = response.data;
		open.value = true;
		formAttrDataMap.value = response.data.attrDataMap
		proxy.modal.closeLoading();
	}).catch(err => {
		Promise.reject(err);
		proxy.modal.closeLoading();
	});
}

/** 提交按钮 */
const umClientUserRef = ref(null)

function submitForm() {
	umClientUserRef.value.validate(valid => {
		if (valid) {
			form.value.attrDataMap = formAttrDataMap.value
			if (form.value.id != null) {
				proxy.modal.loading("提交中");
				updateUmClientUser(form.value).then(response => {
					proxy.modal.msgSuccess("修改成功");
					open.value = false;
					getList();
					proxy.modal.closeLoading();
				}).catch(err => {
					proxy.modal.closeLoading();
					Promise.reject(err);
				});
			} else {
				proxy.modal.loading("提交中");
				addUmClientUser(form.value).then(response => {
					proxy.modal.msgSuccess("新增成功");
					open.value = false;
					getList();
					proxy.modal.closeLoading();
				}).catch(err => {
					proxy.modal.closeLoading();
					Promise.reject(err);
				});
			}
		}
	});
}

/** 删除按钮操作 */
function handleDelete(row) {
	const _ids = row.id || ids.value;
	proxy.modal.confirm('是否确认删除客户端用户编号为"' + _ids + '"的数据项？').then(function () {
		proxy.modal.loading("删除中");
		return delUmClientUser(_ids);
	}).then(() => {
		getList();
		proxy.modal.msgSuccess("删除成功");
		proxy.modal.closeLoading();
	}).catch(() => {
		proxy.modal.closeLoading();
	});
}

/** 导出按钮操作 */
function handleExport() {
	proxy.download.post('um/umClientUser/export', {
		...queryParams.value
	}, `umClientUser_${new Date().getTime()}.xlsx`)
}

/** 状态修改  */
function handleStatusChange(row, key,textFail = "停用",textSuc = "启用") {
	let text = row[key] ? textFail : textSuc;
	proxy.modal.confirm('确认要【' + text + '】"' + row.phone + '"数据项吗?').then(function () {
		return updateUmClientUser({id: row.id, [key]: row[key]});
	}).then(() => {
		proxy.modal.msgSuccess(text + "成功");
	}).catch(function () {
		row[key] = row[key] ? 0 : 1;
	});
};

/** 查询部门下拉树结构 */
const deptOptions = ref(undefined);
watchEffect(() => {
	deptOptions.value = deptStore.deptTree;
});

/** 查询用户属性配置 */
const attrConf = ref([])
const attrConfMap = ref({})
const attrDicts = ref({})
allUmAttrConf().then(res => {
	if (res.data && res.data.length) {
		let dictTypes = res.data.map(item => item.dictType).filter(s => s)
		attrDicts.value = proxy.useDict(...dictTypes)
	}

	attrConfMap.value = {}
	attrConf.value = []
	let attrTypeList = JSON.parse(JSON.stringify(um_attr_type.value));
	attrTypeList.push({ "label": "择偶条件", "value": "condition" })

	attrTypeList.forEach(item => {
		let conf = res.data.filter(s => s.attrType === item.value)
		attrConf.value = attrConf.value.concat(conf)
		attrConfMap.value[item.value] = {
			base: {list: conf.filter(s => s.viewType !== 'imageUpload' && s.viewType !== 'fileUpload' && s.viewType !== 'editor')},
			img: {list: conf.filter(s => s.viewType === 'imageUpload' || s.viewType === 'fileUpload')},
			editor: {list: conf.filter(s => s.viewType === 'editor')},
		}
		Object.keys(attrConfMap.value).forEach(key => {
			const imgSpan = key === 'sign' ? 12 : 6
			attrConfMap.value[key].base.colSpan = 24 - imgSpan * attrConfMap.value[key].img.list.length;
			attrConfMap.value[key].base.subColSpan = 24 / ((24 / imgSpan) - attrConfMap.value[key].img.list.length);
			attrConfMap.value[key].img.colSpan = imgSpan * attrConfMap.value[key].img.list.length;
			attrConfMap.value[key].img.subColSpan = 24 / attrConfMap.value[key].img.list.length;
		})
	})
	attrConf.value.forEach(attr => {
		['textarea','fileUpload','editor'].indexOf(attr.viewType) < 0 &&  columns.value.push({
			label: attr.attrName,
			key: attr.attrCode,
			able: true,
			visible: true,
		})
	})

})
getList();
</script>
